//
//  ThirdViewController.m
//  League
//
//  Created by 博宇 李 on 2018/1/23.
//  Copyright © 2018年 ciyuanjuzhen. All rights reserved.
//

#import "ThirdViewController.h"
#import "ThirdHeadView.h"
#import "MyPreferencesViewController.h"
#import "MyProfileViewController.h"
#import "UserProfileViewController.h"
#import "LoginViewController.h"
#import "ModifyPhoneNumberViewController.h"
#import "ModifyPassWordViewController.h"
#import "ZQTColorSwitch.h"
#import "UserInfomation.h"
#import "SettingModel.h"
#import "RegisterViewController.h"
#import "OCProfileViewController.h"
#import "OCPreferencesViewController.h"
#import "OCRegisterViewController.h"

#define kTitleBgColor [UIColor colorWithRed:237/255.0 green:237/255.0 blue:242/255.0 alpha:1]

#define kRightTitleLiColor [UIColor colorWithRed:142/255.0 green:142/255.0 blue:147/255.0 alpha:1]

#define kOffBgColor [UIColor colorWithRed:230/255.0 green:239/255.0 blue:243/255.0 alpha:1]
#define kFontSize 12

#define kRow2Height 180
#define kRow12Height 55
#define kCellBtnHeight 40
#define kCellBtnSpaceHeight 15

#define kHeadTitleHeight 50

#define kSpace 12
@interface ThirdViewController ()<UITableViewDataSource , UITableViewDelegate,UIScrollViewDelegate>
{
//    NSInteger lastcontentOffset;
    
    BOOL newMatchSwitch;
    BOOL conciergeMessagesSwitch;
    BOOL language;
    NSBundle *bundle;
}
@property(strong , nonatomic)UITableView *tableV;
@property(strong , nonatomic)ThirdHeadView *headView;
@property (nonatomic, assign) NSInteger lastcontentOffset;
@property (nonatomic, strong) SettingModel *model;

@end

@implementation ThirdViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   [self.navigationController setNavigationBarHidden:YES animated:NO];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}
-(void)viewDidDisappear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:kOutLoginNotificationName object:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    newMatchSwitch = YES;
    conciergeMessagesSwitch = YES;
    [InternationalControl initUserLanguage];//初始化应用语言
    
    bundle = [InternationalControl bundle];
    
    
    [self TableView];
    [self HeadView];
    
    [self getUserInfoRequest];
    // Do any additional setup after loading the view.
}
-(void)HeadView
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 30)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    self.headView = [[ThirdHeadView alloc] initWithFrame:CGRectMake(0, view.height, self.view.width, kHeadViewH)];
    self.headView.titleLab.text = [bundle localizedStringForKey:@"Settings" value:nil table:@"hello"];
    self.headView.emailLab.text = @"Cccc";
    self.headView.sinceLab.text = @"Chongqingshi.yuzhongqu";
//    [[UIApplication sharedApplication].keyWindow addSubview:self.headView];
   [self.view addSubview:self.headView];
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapAction:)];
    //为图片添加手势
    self.headView.headImageV.userInteractionEnabled = YES;
    [self.headView.headImageV addGestureRecognizer:singleTap];
    self.headView.headImageV.image = [UIImage imageNamed:@"placeholderImage"];
}
-(void)singleTapAction:(UIGestureRecognizer *)Recog
{
    //具体的实现
    UserProfileViewController *userProfile = [[UserProfileViewController alloc] init];
    [self.navigationController pushViewController:userProfile animated:YES];
}

-(void)TableView
{
    self.tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-50)];//指定位置大小
    self.tableV.backgroundColor = [UIColor clearColor];
    [self.tableV setDelegate:self];//指定委托
    [self.tableV setDataSource:self];//指定数据委托
    self.tableV.estimatedRowHeight = 0;
    self.tableV.estimatedSectionHeaderHeight = 0;
    self.tableV.estimatedSectionFooterHeight = 0;
//    self.tableV.separatorStyle = UITableViewCellSeparatorStyleNone;
    UIView *headfootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.01)];
    self.tableV.tableHeaderView = headfootView;
    self.tableV.tableFooterView = headfootView;
    if (@available(iOS 11.0, *)) {
        self.tableV.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableV];//加载tableview
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return  46;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCell"];
    //    if (!cell) {
    //        cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"TableViewCell"];
    //
    //    }
    static NSString *CellIdentifier = @"TableViewCell";
    // 通过indexPath创建cell实例 每一个cell都是单独的
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    // 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.width = tableView.width;
    }
//
//    cell.textLabel.text= [NSString stringWithFormat:@"%@",@(indexPath.row)];
    if (indexPath.row == 1) {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text =[bundle localizedStringForKey:@"GameChangers" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
    }
    else if (indexPath.row == 2){
        UIButton *buyMoreProBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, cell.width*0.8, kCellBtnHeight)];
        buyMoreProBtn.backgroundColor = kAppColor;
        buyMoreProBtn.center = CGPointMake(cell.width/2, kCellBtnSpaceHeight+buyMoreProBtn.height/2);
        [buyMoreProBtn setTitle:[bundle localizedStringForKey:@"BuyMoreProspects" value:nil table:@"hello"] forState:UIControlStateNormal];
        buyMoreProBtn.titleLabel.font = [UIFont fontWithName:kFontName size:kFontSize];
        buyMoreProBtn.layer.masksToBounds = YES;
        buyMoreProBtn.layer.cornerRadius = 8;
//        [cell addSubview:buyMoreProBtn];
        
        UIButton *boostMyProBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, cell.width*0.8, kCellBtnHeight)];
        boostMyProBtn.backgroundColor = kAppColor;
        boostMyProBtn.center = CGPointMake(cell.width/2, kCellBtnSpaceHeight+boostMyProBtn.height/2+buyMoreProBtn.y+buyMoreProBtn.height);
        [boostMyProBtn setTitle:[bundle localizedStringForKey:@"BoostMyProfole" value:nil table:@"hello"] forState:UIControlStateNormal];
        boostMyProBtn.titleLabel.font = [UIFont fontWithName:kFontName size:kFontSize];
        boostMyProBtn.layer.masksToBounds = YES;
        boostMyProBtn.layer.cornerRadius = 8;
//        [cell addSubview:boostMyProBtn];
        
        
        UIButton *buyMoreTickBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, cell.width*0.8, kCellBtnHeight)];
        buyMoreTickBtn.backgroundColor = kAppColor;
        buyMoreTickBtn.center = CGPointMake(cell.width/2, kCellBtnSpaceHeight+buyMoreTickBtn.height/2+boostMyProBtn.y+boostMyProBtn.height);
        [buyMoreTickBtn setTitle:[bundle localizedStringForKey:@"BuyMoreTickets" value:nil table:@"hello"] forState:UIControlStateNormal];
        buyMoreTickBtn.titleLabel.font = [UIFont fontWithName:kFontName size:kFontSize];
        buyMoreTickBtn.layer.masksToBounds = YES;
        buyMoreTickBtn.layer.cornerRadius = 8;
//        [cell addSubview:buyMoreTickBtn];
        
    }
    else if (indexPath.row == 3)
    {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"Actions" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 4)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"EditMyPreferences" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 5)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"EditMyProfile" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 6)
    {
       cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ChangeMyPhone" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
       [cell addSubview:headLab];
    }
    else if (indexPath.row == 7)
    {
//        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ChangeMyLeagueProfile" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
    }
    else if (indexPath.row == 8)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
//        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"changPW" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
       [cell addSubview:headLab];
    }
    else if (indexPath.row == 9)
    {
        
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ApplicantsEndorsed" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"1";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 10)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ApplicantsAccepted" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"0";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 11)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ReferralQuality" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Majors";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 12)
    {
        UIButton *UseVIPBtnBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, cell.width*0.8, kCellBtnHeight)];
        UseVIPBtnBtn.backgroundColor = kAppColor;
        UseVIPBtnBtn.center = CGPointMake(cell.width/2, kRow12Height/2);
        [UseVIPBtnBtn setTitle:[bundle localizedStringForKey:@"UseVIPTicket" value:nil table:@"hello"] forState:UIControlStateNormal];
        UseVIPBtnBtn.titleLabel.font = [UIFont fontWithName:kFontName size:kFontSize];
        UseVIPBtnBtn.layer.masksToBounds = YES;
        UseVIPBtnBtn.layer.cornerRadius = 8;
//        [cell addSubview:UseVIPBtnBtn];
    }
    else if (indexPath.row == 13)
    {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"MyAccount" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 14)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"AccontType" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = [bundle localizedStringForKey:@"Member" value:nil table:@"hello"];
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 15)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"Username" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = self.model.username;
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 16)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"Name" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = self.model.realName;
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 17)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"LeagueTickets" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = self.model.ticketCount;
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 18)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"VIPPassesRemaining" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"3 Buy More";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 19)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"DateApplied" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = self.model.registerTime;
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 20)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"FriendsinTheleague" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = self.model.friendsCount;
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 21)
    {
//        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"language" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        
        ZQTColorSwitch *mySwitch = [[ZQTColorSwitch alloc]initWithFrame:CGRectMake(0, 0, cell.width/5, kHeadTitleHeight*0.8)];
        mySwitch.center = CGPointMake(cell.width - mySwitch.width/2-5, kHeadTitleHeight/2);
        mySwitch.onBackLabel.text =  [bundle localizedStringForKey:@"opend" value:nil table:@"hello"];
        mySwitch.offBackLabel.text =  [bundle localizedStringForKey:@"offed" value:nil table:@"hello"];
        //中英文切换
        NSString *lan = [InternationalControl userLanguage];
        if([lan isEqualToString:@"en"]){//判断当前的语言，进行改变
            mySwitch.on = YES;
        }else{
            mySwitch.on = NO;
        }
        [mySwitch addTarget:self action:@selector(swChange:) forControlEvents:UIControlEventValueChanged];
        mySwitch.tag = 1003;
        mySwitch.onBackLabel.textColor = [UIColor whiteColor];
        [mySwitch setTintColor:kOffBgColor];
        [mySwitch setOnTintColor:kAppColor];
        [mySwitch setThumbTintColor:[UIColor whiteColor]];
        [cell addSubview:mySwitch];
    }
    else if (indexPath.row == 22)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"LeagueScore" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Majors";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 23)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"Popularity" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Top 40%";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 24)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"Flakiness" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = [bundle localizedStringForKey:@"NotFlaky" value:nil table:@"hello"];
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 25)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"Pickiness" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Open Minded";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 26)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"InitiationRate" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"0%";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 27)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"GhostRate" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Not a Ghost";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 28)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"FlaggedRate" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Never";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 29)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"BlockedRate" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Never";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 30)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"MatchConversionRate" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"Never";
        rightLab.textColor = kAppColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
//        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 31)
    {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"Noftications" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 32)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"NewMatch" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
       
        ZQTColorSwitch *mySwitch = [[ZQTColorSwitch alloc]initWithFrame:CGRectMake(0, 0, cell.width/5, kHeadTitleHeight*0.8)];
        mySwitch.center = CGPointMake(cell.width - mySwitch.width/2-5, kHeadTitleHeight/2);
        mySwitch.onBackLabel.text =  [bundle localizedStringForKey:@"opend" value:nil table:@"hello"];
        mySwitch.offBackLabel.text =  [bundle localizedStringForKey:@"offed" value:nil table:@"hello"];
        if ([self.model.noti_new_match integerValue] == 1) {
            newMatchSwitch = YES;
        } else {
            newMatchSwitch = NO;
        }
        mySwitch.on=newMatchSwitch;
        [mySwitch addTarget:self action:@selector(swChange:) forControlEvents:UIControlEventValueChanged];
        mySwitch.tag = 1000;
        mySwitch.onBackLabel.textColor = [UIColor whiteColor];
        [mySwitch setTintColor:kOffBgColor];
        [mySwitch setOnTintColor:kAppColor];
        [mySwitch setThumbTintColor:[UIColor whiteColor]];
        [cell addSubview:mySwitch];
        
//        [mySwitch setOnTintColor:kAppColor];
//        [mySwitch setThumbTintColor:[UIColor whiteColor]];
//        [mySwitch setTintColor:kAppColor];
//        [mySwitch addTarget:self action:@selector(swChange:) forControlEvents:UIControlEventValueChanged];

    }
    else if (indexPath.row == 33)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ConciergeMessages" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
//        ZQTColorSwitch *mySwitch = [[ZQTColorSwitch alloc]init];
//        mySwitch.frame=CGRectMake(0, 0, 180, 40);
//        mySwitch.center = CGPointMake(cell.width - mySwitch.width/2-5, kHeadTitleHeight/2);
//        mySwitch.on=conciergeMessagesSwitch;
//        mySwitch.tag = 2000;
//        [cell addSubview:mySwitch];
//        [mySwitch setOnTintColor:kAppColor];
//        [mySwitch setThumbTintColor:[UIColor whiteColor]];
//        [mySwitch setTintColor:kAppColor];
//        [mySwitch addTarget:self action:@selector(swChange:) forControlEvents:UIControlEventValueChanged];
        
        ZQTColorSwitch *mySwitch = [[ZQTColorSwitch alloc]initWithFrame:CGRectMake(0, 0, cell.width/5, kHeadTitleHeight*0.8)];
        mySwitch.center = CGPointMake(cell.width - mySwitch.width/2-5, kHeadTitleHeight/2);
        mySwitch.onBackLabel.text =  [bundle localizedStringForKey:@"opend" value:nil table:@"hello"];
        mySwitch.offBackLabel.text =  [bundle localizedStringForKey:@"offed" value:nil table:@"hello"];
        if ([self.model.noti_concierge_message integerValue] == 1) {
            conciergeMessagesSwitch = YES;
        } else {
            conciergeMessagesSwitch = NO;
        }
        mySwitch.on=conciergeMessagesSwitch;
        [mySwitch addTarget:self action:@selector(swChange:) forControlEvents:UIControlEventValueChanged];
        mySwitch.tag = 2000;
        mySwitch.onBackLabel.textColor = [UIColor whiteColor];
        [mySwitch setTintColor:kOffBgColor];
        [mySwitch setOnTintColor:kAppColor];
        [mySwitch setThumbTintColor:[UIColor whiteColor]];
        [cell addSubview:mySwitch];
        
        
    }
    else if (indexPath.row == 34)
    {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"AboutTheLeague" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 35)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"ReadourMission" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 36)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"TermsofService" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 37)
    {
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"JoinOurTeam" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 38)
    {
//        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.text = [bundle localizedStringForKey:@"CurrentVersion" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
        UILabel *rightLab = [[UILabel alloc] initWithFrame:CGRectMake(-kSpace, 0, cell.width, kHeadTitleHeight)];
        rightLab.text = @"1.0";
        rightLab.textColor = kRightTitleLiColor;
        rightLab.textAlignment = NSTextAlignmentRight;
        rightLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:rightLab];
    }
    else if (indexPath.row == 39)
    {
        cell.backgroundColor = kTitleBgColor;
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.backgroundColor = [UIColor clearColor];
        headLab.text = [bundle localizedStringForKey:@"Support" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 40)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.textColor = kAppColor;
        headLab.textAlignment = NSTextAlignmentCenter;
        headLab.text = [bundle localizedStringForKey:@"FAQ" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 41)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.textColor = kAppColor;
        headLab.textAlignment = NSTextAlignmentCenter;
        headLab.text = [bundle localizedStringForKey:@"SendFeedback" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 42)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.textColor = kAppColor;
        headLab.textAlignment = NSTextAlignmentCenter;
        headLab.text = [bundle localizedStringForKey:@"RateUsontheAppStore" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 43)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.textColor = kAppColor;
        headLab.textAlignment = NSTextAlignmentCenter;
        headLab.text = [bundle localizedStringForKey:@"LogOut" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    else if (indexPath.row == 44)
    {
        UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(kSpace, 0, cell.width, kHeadTitleHeight)];
        headLab.textColor = kAppColor;
        headLab.textAlignment = NSTextAlignmentCenter;
        headLab.text = [bundle localizedStringForKey:@"DeactivateAccount" value:nil table:@"hello"];
        headLab.font = [UIFont fontWithName:kFontName size:kFontSize];
        [cell addSubview:headLab];
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return kHeadViewH+30;
    }
//    else if (indexPath.row == 2)
//    {
//        return kRow2Height;
//    }
//    else if (indexPath.row == 12)
//    {
//        return kRow12Height;
//    }
    else if (indexPath.row == 9||indexPath.row ==10||indexPath.row ==11||indexPath.row ==12||indexPath.row == 1||indexPath.row == 2||indexPath.row == 30||indexPath.row == 29||indexPath.row == 28||indexPath.row == 27||indexPath.row == 26||indexPath.row == 25||indexPath.row == 24||indexPath.row == 23||indexPath.row == 22 || indexPath.row == 14 || indexPath.row == 18 || indexPath.row == 7){
        
        return 0;
    }
    else
    {
    return kHeadTitleHeight;
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"row:%@ - section:%@",@(indexPath.row) , @(indexPath.section));
    if (indexPath.row == 4){
        OCPreferencesViewController *vc = [[OCPreferencesViewController alloc] init];
        vc.isRegister = NO;
        [self.navigationController pushViewController:vc animated:YES];
        return;
        
        MyPreferencesViewController *myPref = [[MyPreferencesViewController alloc] init];
        myPref.isRegister = NO;
        [self.navigationController pushViewController:myPref animated:YES];
    }
    else if (indexPath.row == 5)
    {
        OCProfileViewController *vc = [[OCProfileViewController alloc] init];
        vc.isRegister = NO;
        [self.navigationController pushViewController:vc animated:YES];
        return;
        
        MyProfileViewController *Prof = [[MyProfileViewController alloc] init];
        Prof.isRegister = NO;
        [self.navigationController pushViewController:Prof animated:YES];
    }
    else if (indexPath.row == 6)
    {
        NSLog(@"修改手机号");
        ModifyPhoneNumberViewController *modifyPhoneVc = [[ModifyPhoneNumberViewController alloc] init];
        [self.navigationController pushViewController:modifyPhoneVc animated:YES];
    }
    else if (indexPath.row == 7)
    {
//        MyProfileViewController *Prof = [[MyProfileViewController alloc] init];
//        Prof.isRegister = NO;
//        [self.navigationController pushViewController:Prof animated:YES];
        UserProfileViewController *userProfile = [[UserProfileViewController alloc] init];
        [self.navigationController pushViewController:userProfile animated:YES];
    }
    else if (indexPath.row == 8)
    {
        OCRegisterViewController *registerVC = [self  initializeStoryboardViewControllerWithStoryboardID:@"LoginRegister" viewcontroller:@"OCRegisterViewController"];
        registerVC.state = OCForget;
        [self.navigationController pushViewController:registerVC animated:YES];
        return;
        
        RegisterViewController *registerVc = [[RegisterViewController alloc] init];
        registerVc.isForget = YES;
        [self.navigationController pushViewController:registerVc animated:YES];
    }
    else if (indexPath.row == 43)
    {
        ProfileManager *manager = [ProfileManager shareManager];
        manager = nil;
        
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
           [defaults setObject:kNoLoginStr forKey:kIsLogin];
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center postNotificationName:kOutLoginNotificationName object:nil userInfo:nil];
//        LoginViewController *vc = [[LoginViewController alloc] init];
//        [self.navigationController presentViewController:vc animated:YES completion:^{
//
//        }];
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    CGPoint offset = self.tableV.contentOffset;
//    float pyl =  offset.y ;
//    NSLog(@"---%.f",offset.y);
    
    CGFloat hight = scrollView.frame.size.height;
    CGFloat contentOffset = scrollView.contentOffset.y;
    CGFloat distanceFromBottom = scrollView.contentSize.height - contentOffset;
    CGFloat offset = contentOffset - self.lastcontentOffset;
    self.lastcontentOffset = contentOffset;
//    if (offset.y>40) {
//
//    }
//    else if (offset.y==0)
//    {
//       self.headView.titleLab.hidden = NO;
//    }
    
    if (offset > 0 && contentOffset > 0) {
        NSLog(@"上拉行为");
        CGRect headFrame = self.headView.frame;
        CGRect headImageVFrame = self.headView.headImageV.frame;
        CGPoint headImageVPoint = self.headView.headImageV.center;
        CGPoint headNamePoint = self.headView.emailLab.center;
        CGPoint headSincePoint = self.headView.sinceLab.center;
        if (headImageVFrame.size.height >kStopImgWH) {
            headImageVFrame.size.height = headImageVFrame.size.height - 10;
            headImageVFrame.size.width = headImageVFrame.size.width - 10;
            self.headView.headImageV.frame = headImageVFrame;

            //             self.headView.frame = headImageVFrame;
        }
        
     
        NSLog(@"%.f",headFrame.size.height);
        if (headFrame.size.height >kHeadViewStopH) {
            headFrame.size.height = headFrame.size.height - 10;
            self.headView.frame = headFrame;
            headImageVPoint.x = self.headView.width/2;
            headImageVPoint.y = headImageVPoint.y-4;
            self.headView.headImageV.center = headImageVPoint;
            
            headNamePoint.x = self.headView.width/2;
            headNamePoint.y = headNamePoint.y-7.2;
            self.headView.emailLab.center = headNamePoint;
            
//            headSincePoint.x = self.headView.width/2;
//            headSincePoint.y = headSincePoint.y-7;
//            self.headView.sinceLab.center = headSincePoint;
            
            
        }
        else
        {
            self.headView.titleLab.hidden = YES;
            self.headView.sinceLab.hidden = YES;
        }
        
    }
    if (offset < 0 && distanceFromBottom > hight) {
        
        NSLog(@"下拉行为");
        CGRect headFrame = self.headView.frame;
        CGRect headImageVFrame = self.headView.headImageV.frame;
         CGPoint headImageVPoint = self.headView.headImageV.center;
        CGPoint headNamePoint = self.headView.emailLab.center;
        CGPoint headSincePoint = self.headView.sinceLab.center;
        NSLog(@"%.f",headFrame.size.height);
        if (headFrame.size.height <kHeadViewH) {
            headFrame.size.height = headFrame.size.height + 5;
            self.headView.frame = headFrame;
            
        }
        else if (headFrame.size.height == kHeadViewH)
        {
            self.headView.sinceLab.hidden = NO;
            headSincePoint.x = self.headView.width/2;
            headSincePoint.y = self.headView.height- self.headView.sinceLab.height/2;
            self.headView.sinceLab.center = headSincePoint;
            
//            self.headView.titleLab.hidden = NO;
        }
        else if (headFrame.size.height >kHeadViewH-20){
            self.headView.titleLab.hidden = NO;
          
//            self.headView.sinceLab.hidden = NO;
        }
         if (headImageVFrame.size.height <kHeadImgWH) {
             headImageVFrame.size.height = headImageVFrame.size.height + 10;
             headImageVFrame.size.width = headImageVFrame.size.width + 10;
             self.headView.headImageV.frame = headImageVFrame;
             
             headImageVPoint.x = self.headView.width/2;
             headImageVPoint.y = headImageVPoint.y+4;
             self.headView.headImageV.center = headImageVPoint;
             
             headNamePoint.x = self.headView.width/2;
             headNamePoint.y = headNamePoint.y+7;
             self.headView.emailLab.center = headNamePoint;
             
//             headSincePoint.x = self.headView.width/2;
//             headSincePoint.y = headSincePoint.y+7;
//             self.headView.sinceLab.center = headSincePoint;
//              self.headView.frame = headImageVFrame;
         }
        if (headImageVFrame.size.height == kHeadImgWH) {
            headNamePoint.x = self.headView.width/2;
            headNamePoint.y =self.headView.headImageV.y + self.headView.headImageV.height+self.headView.emailLab.height/2;
            self.headView.emailLab.center = headNamePoint;
        }
//        else{
//
//        }
    }
    if (contentOffset == 0) {
        NSLog(@"滑动到顶部");
        self.headView.titleLab.hidden = NO;
        self.headView.sinceLab.hidden = NO;
        CGRect headFrame = self.headView.frame;
          headFrame.size.height = kHeadViewH;
        self.headView.frame = headFrame;
        
        CGPoint headImageVPoint = self.headView.headImageV.center;
        headImageVPoint.x = self.headView.width/2;
     headImageVPoint.y=self.headView.titleLab.height+self.headView.headImageV.height/2;
        self.headView.headImageV.center = headImageVPoint;
        
         CGPoint headNamePoint = self.headView.emailLab.center;
        headNamePoint.x = self.headView.width/2;
        headNamePoint.y=self.headView.headImageV.y+self.headView.headImageV.height+self.headView.emailLab.height/2;
        self.headView.emailLab.center = headNamePoint;
    }
    if (distanceFromBottom < hight) {
        NSLog(@"滑动到底部");
    }
    
//    if (scrollView.contentOffset.y<lastContentOffset)
//
//    {
//
//        NSLog(@"向上");
//
////        self.headView.frame = headFrame;
//
//        //向上
//
//    } else if (scrollView.contentOffset.y>lastContentOffset)
//
//    {
//
//
//        NSLog(@"向下");
//
//        //向下
//
//    }
//   if(offset.y<0)
//   {
//       CGRect headFrame = self.headView.frame;
//       if (headFrame.size.height <kHeadViewH) {
//           headFrame.size.height = kHeadViewH + pyl;
//       }
//       self.headView.frame = headFrame;
//
////       self.headBtn.frame = btnFrame;
////       self.headView.frame.size.height = kHeadViewH - pyl;
//   }
//  else if (offset.y>0) {
//      CGRect headFrame = self.headView.frame;
//      if (headFrame.size.height >80) {
//          headFrame.size.height = kHeadViewH - pyl;
//      }
//      self.headView.frame = headFrame;
//    }
}
- (void) swChange:(UISwitch*) sw{
    if (sw.tag == 1003) {
        //中英文切换
        NSString *lan = [InternationalControl userLanguage];
        if([lan isEqualToString:@"en"]){//判断当前的语言，进行改变
            [InternationalControl setUserlanguage:@"zh-Hans"];
        }else{
            [InternationalControl setUserlanguage:@"en"];
        }
        [InternationalControl initUserLanguage];//初始化应用语言
        bundle = [InternationalControl bundle];
        [self.tableV reloadData];
        return;
    }
    if (sw.tag == 1000) {
        if(sw.on==YES){
            NSLog(@"开关被打开");
            newMatchSwitch = YES;
            self.model.noti_new_match = @"1";
        } else {
            NSLog(@"开关被关闭");
             newMatchSwitch = NO;
            self.model.noti_new_match = @"0";
        }
    }
    else if (sw.tag == 2000)
    {
        if(sw.on==YES){
            NSLog(@"开关被打开");
            conciergeMessagesSwitch = YES;
            self.model.noti_concierge_message = @"1";
        }else{
            NSLog(@"开关被关闭");
            conciergeMessagesSwitch = NO;
            self.model.noti_concierge_message = @"0";
        }
    }
    NSDictionary *dic = @{
                          @"pk":[UserInfomation shareManager].pk,
                          @"notiConciergeMessage":@(conciergeMessagesSwitch),
                          @"notiNewMatch":@(newMatchSwitch)
                          };
    [self noticeReqeustWithParameters:dic];
    [self.tableV reloadData];
}

- (void)noticeReqeustWithParameters:(NSDictionary *)parameters {
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kChangeNotice];
    NSLog(@"urlStr:%@",urlStr);
    [DataContrller PostRequestUrl:urlStr Param:parameters requestSuccess:^(NSDictionary *backDic) {
        NSLog(@"backDic:%@",backDic);
        if ([backDic[@"returnCode"] integerValue] == 200) {
           
        } else {
            
        }
    } requestFail:^(NSString *backErrorStr) {
        
    }];
}

- (void)getUserInfoRequest {
    NSDictionary *dic = @{
                          @"pk":[UserInfomation shareManager].pk
                          };
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",kFirstUrl,kUserInfo];
    NSLog(@"urlStr:%@",urlStr);
    [DataContrller PostRequestUrl:urlStr Param:dic requestSuccess:^(NSDictionary *backDic) {
        NSLog(@"backDic:%@",backDic);
        if ([backDic[@"returnCode"] integerValue] == 200) {
            SettingModel *settingModel = [[SettingModel alloc] initWithDictionary:backDic[@"obj"] error:nil];
            self.model = settingModel;
    
            self.headView.emailLab.text = self.model.username;
            self.headView.sinceLab.text = self.model.email;
            [self.headView.headImageV sd_setImageWithURL:[NSURL URLWithString:self.model.picUrl] placeholderImage:[UIImage imageNamed:@"placeholderImage"]];
            [self.tableV reloadData];
        } else {
            
        }
    } requestFail:^(NSString *backErrorStr) {
        
    }];
}

@end
